#pragma once
#include <json/json.h>
#include <json/reader.h>
#include <json/value.h>

#include <boost/asio.hpp>
#include <boost/beast.hpp>
#include <boost/beast/http.hpp>
#include <boost/filesystem.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/property_tree/ptree.hpp>
#include <chrono>
#include <fstream>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <thread>
#include <unordered_map>

#include "hiredis.h"
#include "Singleton.h"

// 单个日志文件大小不超过5MB
#define FILE_MAX_SIZE 1024 * 1024 * 5

// 日志文件切片最多为10个，超过10个开始覆盖
#define MAX_FILES 10

namespace beast = boost::beast;
namespace http = beast::http;
namespace net = boost::asio;

using tcp = boost::asio::ip::tcp;

using namespace std;

class ConfigMgr;
extern ConfigMgr gCfgMgr;

// 解开注释使用日志功能
// #define LOG_DEBUG

#ifdef LOG_DEBUG

#include "spdlog/sinks/rotating_file_sink.h"
#include "spdlog/spdlog.h"

extern std::shared_ptr<::spdlog::logger> g_logs;

#endif  // DEBUG

enum ErrorCodes {
  Success = 0,
  Error_Json = 1001,      // Json解析错误
  RPCFailed = 1002,       // RPC请求错误
  VarifyExpired = 1003,   // 验证码过期
  VarifyCodeErr = 1004,   // 验证码错误
  UserExist = 1005,       // 用户已经存在
  PasswdErr = 1006,       // 密码错误
  EmailNotMatch = 1007,   // 邮箱不匹配
  PasswdUpFailed = 1008,  // 更新密码失败
  PasswdInvalid = 1009,   // 密码更新失败
  TokenInvalid = 1010,    // Token失效
  UidInvalid = 1011,      // uid无效
};

extern string code_prefix;